<table>
	<tr>
		<td>
			<a class="button" href="<?php echo $this->baseUrl() ?>/cporders/list">
				<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/left_16.png);" class="inb">Wróć do listy</div>
			</a>
		</td>
		<td>
			<a class="button" href="javascript:void(null)" onclick="$('#formitem').submit()">
				<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/save_16.png);" class="inb">Zapisz</div>
			</a>
		</td>
	</tr>
</table>

<h2 style="background:white;padding:14px;text-align:center;">Zamówienie nr: <span style="color:green;"><?php echo $this->item['o_id'] ?></span>, kwota: <span style="color:green;"><?php echo $this->item['price'] . ' ' . $this->item['currency']; ?></span>, złożone dnia: <span style="color:green;"><?php echo $this->item['add_date'] ?></span></h2>


<form id="formitem" action="<?php echo $this->baseUrl() ?>/cporders/item/id/<?php echo $this->item['o_id'] ?>" method="post">
	<table cellspacing="1" cellpadding="6" class="tform">
		<tr style="background:#d1d1d1;">
			<th style="font-size:13px;" colspan="4">Dane do wysyłki</th>
		</tr>
		<tr>
			<?php if($this->item['vouchers_v_id']==0) { ?>
			<td class="labt">Imie i nazwisko:</td>
			<td class="forder"><?php echo $this->item['name_to_dispatch'] . ' ' . $this->item['surname_to_dispatch'] ?></td>
			<td class="labt">Adres:</td>
			<td class="forder">
			<?php echo $this->item['street_to_dispatch'] . ' ' . $this->item['nr_home_to_dispatch']; ?>
			<br />
			<?php echo $this->item['locality_to_dispatch'] . ' ' . $this->item['zip_to_dispatch']; ?>
			<br />
			<?php echo Core_Static::$province[$this->item['province_to_dispatch']] . ' ' . Core_Static::$country[$this->item['country_to_dispatch']]; ?>
			</td>
			<?php } else { ?>
			<td colspan="4" style="text-align:center"><span style="color:#a2a2a2;" title="Zamówiono bon podarunkowy">nie dotyczy</span></td>
			<?php } ?>
		</tr>
	</table>
	
	<table cellspacing="1" cellpadding="6" class="tform">
		<tr style="background:#d1d1d1;">
			<th style="font-size:13px;" colspan="6">Dane do faktury</th>
		</tr>
		<tr>
			<td class="labt">Nazwa firmy i NIP:</td>
			<td class="forder"><?php echo $this->item['company_to_fv'] . ' ' . $this->item['nip_to_fv'] ?></td>
			<td class="labt">Imie i nazwisko:</td>
			<td class="forder"><?php echo $this->item['name_to_fv'] . ' ' . $this->item['surname_to_fv'] ?></td>
			<td class="labt">Adres:</td>
			<td class="forder">
			<?php echo $this->item['street_to_fv'] . ' ' . $this->item['nr_home_to_fv']; echo ($this->item['nr_flat_to_fv'] ? ' / '.$this->item['nr_flat_to_fv'] : '') ?>
			<br />
			<?php echo $this->item['locality_to_fv'] . ' ' . $this->item['zip_to_fv']; ?>
			<br />
			<?php echo Core_Static::$province[$this->item['province_to_fv']] . ' ' . Core_Static::$country[$this->item['country_to_fv']]; ?>
			</td>
		</tr>
	</table>
	
	<?php if( $this->item['Facility']['city_pl'] ) { ?>
	<table cellspacing="1" cellpadding="6" class="tform">
		<tr style="background:#d1d1d1;">
			<th style="font-size:13px;" colspan="2">Odbiór osobisty</th>
		</tr>
		<tr>
			<td class="labt">Salon:</td>
			<td class="forder">
				<?php echo $this->item['Facility']['city_pl'] ?>
			</td>
		</tr>
	</table>
	<?php } ?>
	
	<table cellspacing="1" cellpadding="6" class="tform">
		<tr style="background:#d1d1d1;">
			<th style="font-size:13px;" colspan="10">Status zamówienia</th>
		</tr>
		<tr>
			<td class="labt">Zapłacone:</td>
			<td class="forder">
				<?php echo $this->formSelect( 'state', $this->item['state'], null, array( 'Nie', 'Tak' ) ) ?>
			</td>
			
			<td class="labt">Potwierdzone:</td>
			<td class="forder">
				<?php echo $this->formSelect( 'state2', $this->item['state2'], null, array( 'Nie', 'Tak' ) ) ?>
			</td>
			
			<td class="labt">Przygotowane:</td>
			<td class="forder">
				<?php echo $this->formSelect( 'state3', $this->item['state3'], null, array( 'Nie', 'Tak' ) ) ?>
			</td>
			
			<td class="labt">Wysłane:</td>
			<td class="forder">
				<?php echo $this->formSelect( 'state4', $this->item['state4'], null, array( 'Nie', 'Tak' ) ) ?>
			</td>
			
			<td class="labt">Zrealizowane:</td>
			<td class="forder">
				<?php echo $this->formSelect( 'state5', $this->item['state5'], null, array( 'Nie', 'Tak' ) ) ?>
			</td>
		</tr>
	</table>
	
	<table cellspacing="1" cellpadding="6" class="tform">
		<tr style="background:#d1d1d1;">
			<th style="font-size:13px;" colspan="4">Szczegóły zamówienia</th>
		</tr>
		<tr style="background:#d1d1d1;">
			<th style="font-size:13px;text-align:left;">Produkt</th>
			<th style="font-size:13px;text-align:left;">Produkt specjalny</th>
			<th style="font-size:13px;text-align:left;">Rozmiar</th>
			<th style="font-size:13px;text-align:left;">Ilość</th>
		</tr>

		<?php if($this->item['vouchers_v_id']>0){ ?>
		
			<tr>
			<td>
			<?php 
			    $vouModel = new Vouchers;
			    $vouItem = $vouModel->getItemService($this->item['vouchers_v_id'])->toArray();
			    $vouItem = $vouItem[0];
			?>
			BON PODARUNKOWY O WARTOŚCI <?php echo $vouItem['value'] ?>
			</td>
			<td><span style="color:#a2a2a2;" title="Zamówiono bon podarunkowy">nie dotyczy</span></td>
			<td><span style="color:#a2a2a2;" title="Zamówiono bon podarunkowy">nie dotyczy</span></td>
			<td><span style="color:#a2a2a2;" title="Zamówiono bon podarunkowy">nie dotyczy</span></td>
			</tr>
		
		<?php } ?>

		<?php foreach( $this->item['OrdersItems'] as $elem ) { ?>
			
    		 
    		<?php if($elem['special']==1){ ?>
    		    	
    		        <?php 
    		        //Produkt specjalny
    		        $pspecialModel = new ProductsSpecial;
    		        $specialItem = $pspecialModel->getItem($elem['products_p_id'])->toArray();
    		        $specialItem =  $specialItem[0];
    		        ?>
    		        <tr>
        			<td>
        				<?php echo $specialItem['name_pl'] ?>
        			</td>
        			<td>
        				TAK
        			</td>
        			<td>
						nie dotyczy
        			</td>
        			<td>
        				<?php echo $elem['items'] ?>
        			</td>
        			</tr>       
    		        
    		<?php  } else { ?>		
    				<tr>
        			<td>
        				<?php echo $elem['Products']['name_pl'] ?>
        			</td>
        			<td>
        				NIE
        			</td>
        			<td>
        				<?php foreach( $elem['Products']['Dimension'] as $v2 ) {
        					if( $elem['dimension_d_id'] == $v2['d_id'] ) {
        						echo $v2['name'];
        						break;
        					} 
        				} ?>
        			</td>
        			<td>
        				<?php echo $elem['items'] ?>
        			</td>
        			</tr>
    			<?php } ?>
		<?php } ?>
	
	</table>
</form>

<table>
	<tr>
		<td>
			<a class="button" href="<?php echo $this->baseUrl() ?>/cporders/list">
				<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/left_16.png);" class="inb">Wróć do listy</div>
			</a>
		</td>
		<td>
			<a class="button" href="javascript:void(null)" onclick="$('#formitem').submit()">
				<div style="background:url(<?php echo $this->baseUrl() ?>/public/images/save_16.png);" class="inb">Zapisz</div>
			</a>
		</td>
	</tr>
</table>